/*
package org.pearl.validation.demo.config;

import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.api.sharding.complex.ComplexKeysShardingAlgorithm;
import org.apache.shardingsphere.api.sharding.standard.PreciseShardingAlgorithm;
import org.apache.shardingsphere.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.api.sharding.standard.RangeShardingAlgorithm;
import org.apache.shardingsphere.api.sharding.standard.RangeShardingValue;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

*/
/**
 * Created by TD on 2021/6/11
 * Sharding  自定义分片规则
 *
 *//*

@Slf4j
public class AAA      implements PreciseShardingAlgorithm<Long>, RangeShardingAlgorithm<Long> {


    */
/**

     * Sharding.

     *

     * @param availableTargetNames available data sources or tables's names （当前维护的数据库源列表）

     * @param shardingValue sharding value (表名，分库表的列字段名，分库表的列字段值)

     * @return sharding result for data source or table's name （返回分库的库名）

     *//*


    @Override
    public String doSharding(Collection<String> availableTargetNames, PreciseShardingValue<Long> shardingValue) {
        // 真实节点
        availableTargetNames.forEach(item -> log.info("actual node db:{}", item));

        log.info("logic table name:{},rout column:{}", shardingValue.getLogicTableName(), shardingValue.getColumnName());

        //精确分片
        log.info("column value:{}", shardingValue.getValue());

        for (String each : availableTargetNames) {
            Long value = shardingValue.getValue();
            if (("ds" + value % 2).equals(each)) {
                return each;
            }
        }

        return null;
    }

    @Override
    public Collection<String> doSharding(Collection<String> collection, RangeShardingValue<Long> rangeShardingValue) {
        return collection;
    }
}
*/
